/*
 * Copyright 2025 arisgo@163.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.arisgo.cloud.auth.sys.service.impl;

import com.arisgo.cloud.auth.sys.vo.FunctionVo;
import com.arisgo.cloud.common.Pagination;
import com.arisgo.cloud.common.utils.AssertUtil;
import com.arisgo.cloud.web.mybatis.service.CloudServiceImpl;
import java.sql.Date;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

import com.arisgo.cloud.auth.sys.mapper.TenantFunctionMapper;
import com.arisgo.cloud.auth.sys.service.TenantFunctionService;
import com.arisgo.cloud.auth.sys.entity.TenantFunction;
import com.arisgo.cloud.auth.sys.vo.TenantFunctionVo;
import com.arisgo.cloud.web.param.Paging;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

/**
 * 租户功能
 *
 * @author Arisgo
 * @since 2024-06-14
 */
@Service
public class TenantFunctionServiceImpl extends CloudServiceImpl<TenantFunctionMapper, TenantFunction, TenantFunctionVo> implements TenantFunctionService {

    @Override
    public TenantFunction getInstanceModel() {
        return new TenantFunction();
    }

    @Override
    public TenantFunctionVo getInstanceVo() {
        return new TenantFunctionVo();
    }

    @Override
    public Pagination<TenantFunctionVo> pageFunctionByTenantId(Paging paging) {
        PageHelper.startPage(paging.getPageNo(), paging.getPageSize());
        PageInfo<TenantFunctionVo> page = new PageInfo<>(this.mapper.findFunctionByParams(paging.convertMap()));
        return Pagination.creator(paging.getPageNo(), paging.getPageSize(), page.getPages(), page.getTotal(), page.getList());
    }

}
